#include <stdio.h>
#include "linkstack.h"

//用线性表的链式存储来模拟栈时
//在头部添加和删除,不会涉及到数组的元素大量的移动
//所以在头部这一端操作好
int main(int argc, char const *argv[])
{
        int i = 0;
        int a[10] = {0};

        LinkStack* stack = NULL;

        stack = LinkStack_Create();
        if(stack == NULL){
                printf("stack create error\n");
                return -1;
        }

        //压栈
        for ( i = 0; i < 5; i++){
                a[i] = i+1;
                LinkStack_Push(stack, &a[i]);
        }

        printf("栈的大小:%d\n", LinkStack_Size(stack));
        printf("top:%d\n", *((int *)LinkStack_Top(stack)) );

        //删除栈元素
        while ( LinkStack_Size(stack) > 0 ){
                int tmp = *((int *)LinkStack_Pop(stack));
                printf("%d ", tmp);
        }
        printf("\n");

        //销毁栈
        LinkStack_Destory(stack);
        return 0;
}
